//
//  SLCAGradientLayerController.m
//  Objective-C
//
//  Created by S_Line on 2018/6/29.
//  Copyright © 2018年 S_Line. All rights reserved.
//

#import "SLCAGradientLayerController.h"

#import "GradientView.h"

@interface SLCAGradientLayerController ()

@property (nonatomic, weak) GradientView *gradientView;

@end

@implementation SLCAGradientLayerController

- (void)initNavBar {
    self.navTitle = @"CAGradientLayer";
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initNavBar];
    
    [self initView];
}

- (void)initView {
    GradientView *gradientView = [[GradientView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    self.gradientView = gradientView;
    gradientView.colors = @[[UIColor redColor], [UIColor orangeColor], [UIColor yellowColor], [UIColor greenColor], [UIColor cyanColor], [UIColor blueColor], [UIColor purpleColor]];
    gradientView.startPoint = CGPointMake(0, 0);
    gradientView.endPoint = CGPointMake(1, 1);
    [self.view addSubview:gradientView];
    
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight + 20, 100, 40)];
    [button setTitle:@"变化" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}

- (void)buttonClick:(UIButton *)sender {
    [UIView animateWithDuration:0.5 animations:^{
        self.gradientView.frame = CGRectMake(50, 100, 200, 200);
    }];
}

@end
